/**package com.mla.fastdfs.service;

import com.mla.fastdfs.commom.RedisConstant;
import com.mla.fastdfs.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.meta.api.methods.GetFile;
import org.telegram.telegrambots.meta.api.objects.Document;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.Video;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;

import java.util.Arrays;
import java.util.List;

@Slf4j
@Service
public class TelegramRobotService extends TelegramLongPollingBot {

    private String[] suffixs = {".mov", ".avi", ".wmv", ".rm", ".flv"};

    @Value("${telegram.bot.botName}")
    private String botName;

    @Value("${telegram.bot.botToken}")
    private String botToken;

    @Autowired
    private RedisUtil redisUtil;


    @Override
    public void onUpdateReceived(Update update) {
        try {
            if (update.hasChannelPost()) {
                Message message = update.getChannelPost();
                //处理视频
                if (message.hasVideo()) {
                    //接受到视频文件
                    Video video = message.getVideo();
                    getPath(video.getFileId(), 0);
                }
                if (message.hasDocument()) {
                    Document document = message.getDocument();
                    String fileName = document.getFileName();
                    String fileSuffix = fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
                    List<String> list = Arrays.asList(suffixs);
                    if (list.contains(fileSuffix)) {
                        getPath(document.getFileId(), 0);
                    }
                }
            }
        } catch (Exception e) {
            log.error("接受视频异常");
            log.error(e.getMessage(), e);
        }
    }

    private void getPath(String fileId, int i) {
        GetFile getFile = new GetFile();
        getFile.setFileId(fileId);
        try {
            org.telegram.telegrambots.meta.api.objects.File file = execute(getFile);
            String fillePath = file.getFileUrl(botToken);
            log.info("频道视频地址：" + fillePath);
            log.info(file.toString());
            redisUtil.hset(RedisConstant.TELE_DOWN, fillePath, 0);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            if (i >= 5) return;//异常后重新尝试获取地址，最多尝试5次
            getPath(fileId, ++i);
        }
    }

    @Override
    public String getBotUsername() {
        return botName;
    }

    @Override
    public String getBotToken() {
        return botToken;
    }
}
**/